<%@page import="accessor.CustomerAccessor"%>
<%@page import="accessor.Customer"%>
<%@page import="java.util.List"%>
<%@include file="header.jsp" %>
<%@include file="menubar/customer_menu.jsp" %>
<div class="break_line"></div>
<div class="break_line"></div>
<div id="content">
    <div id="title_content">UPDATE CUSTOMER</div>
    <form method="POST" action="../update_customer">
        <%
            CustomerAccessor customerAccessor = new CustomerAccessor();
            int customerID = request.getParameter("customerID") != null ? Integer.parseInt(request.getParameter("customerID")) : 0;
            Customer customer = customerAccessor.getCustomerByID(customerID);
        %>
        <% if (request.getSession().getAttribute("updateCusError") != null) {%>
        <div class="form_error" style="padding: 5px;">
                        <% out.println(request.getSession().getAttribute("updateCusError"));%>
                    </div>
                    <%}%>
        <input type="hidden" name="customerID" value="<%= customer != null ? customer.getCustomerID() : ""%>"/>
        <table class="form_content" width="100%">
            <tr>
                <td>FIRST NAME: </td>
                <td>
                    <% if (request.getSession().getAttribute("update_customer_firstname") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_customer_firstname"));%>
                    </div>
                    <%}%>
                    <input type="text" name="first_name" class="form_input" value="<%= customer != null ? customer.getFirstName() : ""%>"/></td>
            </tr>
            <tr>
                <td>LAST NAME: </td>
                <td>
                    <% if (request.getSession().getAttribute("update_customer_lastname") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_customer_lastname"));%>
                    </div>
                    <%}%>
                    <input type="text" name="last_name" class="form_input" value="<%= customer != null ? customer.getLastName() : ""%>"/>
                </td>
            </tr>
            <tr>
                <td>COMPANY: </td>
                <td>
                     <% if (request.getSession().getAttribute("update_customer_company") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_customer_company"));%>
                    </div>
                    <%}%>
                    <input type="text" name="company" class="form_input" value="<%= customer != null ? customer.getCompany() : ""%>"/>
                </td>
            </tr>
            <tr>
                <td>ADDRESS: </td>
                <td>
                    <% if (request.getSession().getAttribute("update_customer_address") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_customer_address"));%>
                    </div>
                    <%}%>
                    <input type="text" name="address" class="form_input" value="<%= customer != null ? customer.getAddress() : ""%>"/>
                </td>
            </tr>
            <tr>
                <td>PHONE </td>
                <td>
                    <% if (request.getSession().getAttribute("update_customer_phone") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_customer_phone"));%>
                    </div>
                    <%}%>
                    <input type="text" name="phone" class="form_input" value="<%= customer != null ? customer.getPhone() : ""%>"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td colspan="2"><input type="submit" name="submit" class="form_input" style="width: 100px;" value="Update"/></td>
            </tr>
        </table>
    </form>
</div>
<!--END content-->
<%@include file="footer.jsp" %>